package fr.ssd.sic.config;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Configurator {
	
	protected static final String propertiesFile = "sic.properties";
	
	public static Properties properties = new Properties();
	
	protected static final String serverHostKey = "imap.server.host";
	public static String serverHost = null;
	
	protected static final String userNameKey = "imap.user.name";
	public static String userName = null;
	
	protected static final String userPasswordKey = "imap.user.password";
	public static String userPassword = null;
	
	protected static final String rootFolderKey = "imap.folder.root";
	public static String rootFolder = null;
	
	protected static final String protocolKey = "imap.protocol";
	public static String protocol = null;

	protected static final String trustStorePathKey = "javax.net.ssl.trustStore";
	public static String trustStorePath = null;
	
	protected static final String lookAndFeelKey = "ui.lookAndFeel";
	public static String lookAndFeel = null;
	
	public static void load() throws IOException{
		InputStream is = new FileInputStream(propertiesFile);
		properties.load(is);
		
		serverHost = (String) properties.getProperty(serverHostKey);
		userName = (String) properties.getProperty(userNameKey);
		userPassword = (String) properties.getProperty(userPasswordKey);
		trustStorePath = (String) properties.getProperty(trustStorePathKey);
		rootFolder = (String) properties.getProperty(rootFolderKey);
		protocol = (String) properties.getProperty(protocolKey);
		lookAndFeel = (String) properties.getProperty(lookAndFeelKey);
		
		System.setProperty(trustStorePathKey, trustStorePath);
	}
}
